home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_2 / turbo1.zip / FSSERIAL.ZIP / ANSIVIEW.PAS next >
Pascal/Delphi Source File  |  1991-01-29  |  20KB  |  705 lines

  1. Unit AnsiView;
  2.  
  3. {     ANSIVIEW.PAS - 24 January 1991
  4.  
  5.                           By Marcos R. Della
  6.                              5084 Rincon Ave.
  7.                              Santa Rosa, CA 95409
  8.  
  9.                              CIS: 71675,765
  10.  
  11.       This Unit was written so that I had something that reminded me of the
  12.       original WRITELN and WRITE statments of pascal where I was working
  13.       with the screen and there were various definate controls I had using
  14.       the GOTOXY and CLRSCR routines.  Under TVision, you no longer have
  15.       these controls and need to learn a completely different way of getting
  16.       info on the screen.
  17.  
  18.       AnsiView was written to give you some of these old methods while still
  19.       using the TVision platform. That is, your screen is a scroll window of
  20.       your size choosing (You can define a screen 128,2048 and use the gotoxy
  21.       to get to anywhere on that screen!)  Also if you turn on the ANSI
  22.       option, the driver will recognise ANSI controls (For reading those ANSI
  23.       files directly and displaying them!)
  24.  
  25.       Because this is also a TVision enviroment, your screen will also be
  26.       saved if you do a desktop save! Wonderful stuff eh?
  27.  
  28.  
  29.       NOTE!!!   Registration values used by this Unit
  30.  
  31.                     TANSIView = 7200;
  32.                     TInterior = 7201;
  33.  
  34.       --------------------
  35.       Modification History
  36.       --------------------
  37.  
  38.       29 January 1991 - Added the code to handle 15 of the ANSI control
  39.                         characters if they are passed to the ANSIView
  40.       routines.  There are two commands that will no work with this current
  41.       implementation. The <ESC>[xP and <ESC>[x@ for insert and delete
  42.       characters on the current line.  These should be supported in the
  43.       near future whenever I get back to working on this unit...
  44.  
  45.       There is a problem with the cursor positioning not always updating
  46.       the onscreen cursor display (if you have it on) however with the
  47.       printing of any character or other command, it comes back on. I'm
  48.       still scratching my head over this one.
  49. }
  50.  
  51. {$F+,O+,R-,S-}
  52.  
  53. Interface
  54.  
  55. Uses Dos, Drivers, Views, Objects, Memory;
  56.  
  57. CONST MaxViewHeight = 2048;
  58.  
  59. TYPE  PScreenL  = ^TScreenL;
  60.       TScreenL  = ARRAY[0..MaxViewWidth - 1] OF WORD;
  61.  
  62.       PScreenR  = ^TScreenR;
  63.       TScreenR  = ARRAY[0..MaxViewHeight - 1] OF PScreenL;
  64.  
  65.       PInterior = ^TInterior;
  66.       TInterior = OBJECT(TScroller)
  67.                      AutoScroll : BOOLEAN;
  68.                      MaxDim     : TPoint;
  69.                      CurLoc     : TPoint;
  70.                      TopPtr     : PScreenR;
  71.                      CONSTRUCTOR Init(VAR Bounds : TRect; Limits : TPoint;
  72.                                           Color : BYTE; AHScrollBar, AVScrollBar : PScrollBar);
  73.                      CONSTRUCTOR Load(VAR S : TStream);
  74.                      PROCEDURE Store(VAR S : TStream);
  75.                      PROCEDURE Draw; VIRTUAL;
  76.                      PROCEDURE PrintChar(Ch : CHAR; VAR TextAttr : BYTE);
  77.                      DESTRUCTOR Done; VIRTUAL;
  78.                   END;
  79.  
  80.       ParmsFld  = ARRAY[1..9] OF BYTE;
  81.  
  82.       PANSIView = ^TANSIView;
  83.       TANSIView = OBJECT(TWindow)
  84.                      UseANSI    : BOOLEAN;
  85.                      StateInfo  : BYTE;
  86.                      ESCBuf     : STRING[126];
  87.                      ANSIParms  : ParmsFld;
  88.                      ParmsIdx   : BYTE;
  89.                      EndString  : CHAR;
  90.                      CurHold    : TPoint;
  91.  
  92.                      TextAttr : BYTE;
  93.                      Interior : PInterior;
  94.                      CONSTRUCTOR Init(Bounds : TRect; Limits : TPoint; WnTitle : STRING; WindowNo : WORD);
  95.                      CONSTRUCTOR Load(VAR S : TStream);
  96.                      PROCEDURE Store(VAR S : TStream);
  97.                      FUNCTION  ProcessChar(Ch : CHAR) : BOOLEAN;
  98.  
  99.                      PROCEDURE PrintLN(s : STRING);
  100.                      PROCEDURE Print(s : STRING);
  101.                      PROCEDURE PrintChar(Ch : CHAR);
  102.                      PROCEDURE PutChar(X, Y : WORD; Ch : CHAR; Attr : BYTE);
  103.  
  104.                      PROCEDURE CursorOn;
  105.                      PROCEDURE CursorOff;
  106.                      PROCEDURE AutoScrollOn;
  107.                      PROCEDURE AutoScrollOff;
  108.  
  109.                      PROCEDURE ClrScr;
  110.                      PROCEDURE ClrEol;
  111.                      PROCEDURE DelLine;
  112.                      PROCEDURE GotoXY(X,Y : WORD);
  113.                      PROCEDURE HighVideo;
  114.                      PROCEDURE InsLine;
  115.                      PROCEDURE LowVideo;
  116.                      PROCEDURE TextBackground(Color : BYTE);
  117.                      PROCEDURE TextColor(Color : BYTE);
  118.                      FUNCTION WhereX : BYTE;
  119.                      FUNCTION WhereY : WORD;
  120.                   END;
  121.  
  122. CONST RANSIView: TStreamRec = (
  123.          ObjType: 7200;
  124.          VmtLink: Ofs(TypeOf(TANSIView)^);
  125.          Load:    @TANSIView.Load;
  126.          Store:   @TANSIView.Store
  127.       );
  128.  
  129.       RInterior: TStreamRec = (
  130.          ObjType: 7201;
  131.          VmtLink: Ofs(TypeOf(TInterior)^);
  132.          Load:    @TInterior.Load;
  133.          Store:   @TInterior.Store
  134.       );
  135.  
  136. PROCEDURE RegisterANSIView;
  137.  
  138. Implementation
  139.  
  140. {----------------------------------------------------------------------------}
  141.  
  142. FUNCTION Min(X,Y : INTEGER) : INTEGER; ASSEMBLER;
  143. ASM
  144.    MOV   AX,X
  145.    CMP   AX,Y
  146.    JLE   @@1
  147.    MOV   AX,Y
  148. @@1:
  149. END;
  150.  
  151. FUNCTION Max(X,Y : INTEGER) : INTEGER; ASSEMBLER;
  152. ASM
  153.    MOV   AX,X
  154.    CMP   AX,Y
  155.    JGE   @@1
  156.    MOV   AX,Y
  157. @@1:
  158. END;
  159.  
  160. {----------------------------------------------------------------------------}
  161.  
  162. CONSTRUCTOR TInterior.Init;
  163. VAR   i,j : WORD;
  164. BEGIN
  165.    TScroller.Init(Bounds,AHScrollBar,AVScrollBar);
  166.    MaxDim     := Limits;
  167.    AutoScroll := TRUE;
  168.    CurLoc.X   := 0;
  169.    CurLoc.Y   := 0;
  170.    TopPtr := MemAlloc(MaxDim.Y * SIZEOF(PScreenR));     {Allocate All Y Coords}
  171.    IF TopPtr = NIL THEN
  172.       BEGIN
  173.          TScroller.Done;
  174.          FAIL
  175.       END;
  176.    FOR i := 0 TO MaxDim.Y - 1 DO BEGIN                  {Now for each line}
  177.       TopPtr^[i] := MemAlloc(MaxDim.X * SIZEOF(WORD));
  178.       IF TopPtr^[i] = NIL THEN
  179.          BEGIN
  180.             IF i > 0 THEN
  181.                FOR j := 0 TO i - 1 DO
  182.                   FREEMEM(TopPtr^[j],MaxDim.X * SIZEOF(WORD));
  183.             FREEMEM(TopPtr,MaxDim.Y * SIZEOF(PScreenR));
  184.             TScroller.Done;
  185.             FAIL
  186.          END
  187.       ELSE
  188.          MoveChar(TopPtr^[i]^,' ',Color,MaxDim.X)
  189.    END;
  190.    GrowMode := gfGrowHiX + gfGrowHiY;
  191.    DragMode := dmLimitLoX + dmLimitLoY;
  192.    SetLimit(MaxDim.X,MaxDim.Y);
  193. END;
  194.  
  195. CONSTRUCTOR TInterior.Load;
  196. VAR   i,j : INTEGER;
  197.       ok  : BOOLEAN;
  198.       B   : TDrawBuffer;
  199. BEGIN
  200.    TScroller.Load(S);
  201.    S.Read(AutoScroll,SIZEOF(AutoScroll));
  202.    S.Read(CurLoc,SIZEOF(CurLoc));
  203.    S.Read(MaxDim,SIZEOF(MaxDim));
  204.    TopPtr := MemAlloc(MaxDim.Y * SIZEOF(PScreenR));
  205.    ok := (TopPtr <> NIL);
  206.    FOR i := 0 TO MaxDim.Y - 1 DO BEGIN
  207.       S.Read(B,MaxDim.X * SIZEOF(WORD));
  208.       IF ok THEN
  209.          BEGIN
  210.             TopPtr^[i] := MemAlloc(MaxDim.X * SIZEOF(WORD));
  211.             ok := ok AND (TopPtr^[i] <> NIL);
  212.             IF ok THEN
  213.                MOVE(B,TopPtr^[i]^,MaxDim.X * SIZEOF(WORD))
  214.             ELSE
  215.                IF i > 0 THEN
  216.                   FOR j := 0 TO i - 1 DO
  217.                      FREEMEM(TopPtr^[j],MaxDim.X * SIZEOF(WORD));
  218.          END
  219.    END;
  220.    IF NOT ok THEN
  221.       BEGIN
  222.          FREEMEM(TopPtr,MaxDim.Y * SIZEOF(PScreenR));
  223.          TScroller.Done;
  224.          FAIL
  225.       END;
  226.    GrowMode := gfGrowHiX + gfGrowHiY;
  227.    SetLimit(MaxDim.X,MaxDim.Y)
  228. END;
  229.  
  230. PROCEDURE TInterior.Store;
  231. VAR   i : INTEGER;
  232. BEGIN
  233.    TScroller.Store(S);
  234.    S.Write(AutoScroll,SIZEOF(AutoScroll));
  235.    S.Write(CurLoc,SIZEOF(CurLoc));
  236.    S.Write(MaxDim,SIZEOF(MaxDim));
  237.    FOR i := 0 TO MaxDim.Y - 1 DO
  238.       S.Write(TopPtr^[i]^,MaxDim.X * SIZEOF(WORD));
  239. END;
  240.  
  241. PROCEDURE TInterior.Draw;
  242. VAR   Y : INTEGER;
  243. BEGIN
  244.    FOR Y := 0 TO Size.Y - 1 DO
  245.       WriteLine(0,Y,Size.X,1,TopPtr^[Delta.Y + Y]^[Delta.X])
  246. END;
  247.  
  248. PROCEDURE TInterior.PrintChar;
  249. VAR   PPtr : PScreenL;
  250.       Y    : INTEGER;
  251. BEGIN
  252.    CASE ch OF
  253.       #0  : ;
  254.       #8  : DEC(CurLoc.X);
  255.       #10 : INC(CurLoc.Y);
  256.       #13 : CurLoc.X := 0;
  257.       ELSE  BEGIN
  258.                MoveChar(TopPtr^[CurLoc.Y]^[CurLoc.X],ch,TextAttr,1);
  259.                INC(CurLoc.X)
  260.             END;
  261.    END;
  262.  
  263.    {Next insure that the X position didn't go out of bounds.}
  264.    {If it did, then set it back in bounds and scroll if needed.}
  265.  
  266.    CurLoc.X := Max(CurLoc.X,0);
  267.    IF CurLoc.X >= MaxDim.X THEN
  268.       BEGIN
  269.          INC(CurLoc.Y);
  270.          CurLoc.X := 0
  271.       END;
  272.  
  273.    {Finally check to see if we went beyond the Y Coordinate and need to}
  274.    {scroll the screen up a line for the next line to be put on.}
  275.  
  276.    IF CurLoc.Y >= MaxDim.Y THEN
  277.       BEGIN
  278.          DEC(CurLoc.Y);
  279.          PPtr := TopPtr^[0];
  280.  
  281.          MoveChar(PPtr^,' ',TextAttr,MaxDim.X);
  282.          MOVE(TopPtr^[1],TopPtr^[0],(MaxDim.Y - 1) * SIZEOF(PScreenL));
  283.          TopPtr^[MaxDim.Y - 1] := PPtr;
  284.          DrawView
  285.       END;
  286.  
  287.    IF AutoScroll AND (Size.Y <= CurLoc.Y - Delta.Y) THEN
  288.       VScrollBar^.SetValue(Max(CurLoc.Y - Size.Y + 1,0));
  289.    Cursor.X := CurLoc.X - Delta.X;
  290.    Cursor.Y := CurLoc.Y - Delta.Y
  291. END;
  292.  
  293.  
  294. DESTRUCTOR TInterior.Done;
  295. VAR   i : WORD;
  296. BEGIN
  297.    FOR i := 0 TO MaxDim.Y - 1 DO
  298.       FREEMEM(TopPtr^[i],MaxDim.X * SIZEOF(WORD));
  299.    FREEMEM(TopPtr,MaxDim.Y * SIZEOF(PScreenR));
  300.    TScroller.Done
  301. END;
  302.  
  303. {----------------------------------------------------------------------------}
  304.  
  305. CONSTRUCTOR TANSIView.Init;
  306. VAR   HScrollBar,
  307.       VScrollBar : PScrollBar;
  308. BEGIN
  309.    TWindow.Init(Bounds,WnTitle,WindowNo);
  310.  
  311.    TextAttr := $1E;
  312.  
  313.    GetExtent(Bounds);
  314.    Bounds.Grow(-1,-1);
  315.  
  316.    Limits.X := Max(Limits.X,MinWinSize.X);
  317.    Limits.X := Min(Limits.X,MaxViewHeight);
  318.    Limits.X := Max(Limits.X,Bounds.B.X - Bounds.A.X);
  319.  
  320.    Limits.Y := Max(Limits.Y,MinWinSize.Y);
  321.    Limits.Y := Min(Limits.Y,MaxViewWidth);
  322.    Limits.Y := Max(Limits.Y,Bounds.B.Y - Bounds.A.Y);
  323.  
  324.    VScrollBar := StandardScrollBar(sbVertical);
  325.    HScrollBar := StandardScrollBar(sbHorizontal);
  326.    Interior := NEW(PInterior,Init(Bounds,Limits,TextAttr,HScrollBar,VScrollBar));
  327.    IF Interior = NIL THEN
  328.       BEGIN
  329.          TWindow.Done;
  330.          FAIL
  331.       END;
  332.    UseANSI := TRUE;
  333.    StateInfo := 0;
  334.    ESCBuf := '';
  335.    CurHold.X := 0;
  336.    CurHold.Y := 0;
  337.    Insert(Interior)
  338. END;
  339.  
  340. CONSTRUCTOR TANSIView.Load;
  341. BEGIN
  342.    TWindow.Load(S);
  343.    GetPeerViewPtr(S,Interior);
  344.    S.Read(TextAttr,SIZEOF(TextAttr));
  345.    S.Read(UseANSI,SIZEOF(UseANSI));
  346.    S.Read(CurHold,SIZEOF(CurHold));
  347.    StateInfo := 0;
  348.    ESCBuf := ''
  349. END;
  350.  
  351. PROCEDURE TANSIView.Store;
  352. BEGIN
  353.    TWindow.Store(S);
  354.    PutPeerViewPtr(S,Interior);
  355.    S.Write(TextAttr,SIZEOF(TextAttr));
  356.    S.Write(UseANSI,SIZEOF(UseANSI));
  357.    S.Write(CurHold,SIZEOF(CurHold));
  358. END;
  359.  
  360. FUNCTION TANSIView.ProcessChar(Ch : CHAR) : BOOLEAN;
  361.  
  362.    PROCEDURE ChangeTextAttr(VAR TAttr : BYTE; PNum : BYTE; PFld : ParmsFld);
  363.    CONST Colors = 22;
  364.          ColorTbl : ARRAY[1..Colors,1..3] OF BYTE =
  365.                     ((0,  $00, $07),   (5,  $FF, $80),
  366.                      (1,  $FF, $08),   (7,  $F8, $70),
  367.                      (4,  $F8, $01),   (8,  $88, $00),
  368.  
  369.                      (30, $F8, $00),   (40, $8F, $00),
  370.                      (31, $F8, $04),   (41, $8F, $40),
  371.                      (32, $F8, $02),   (42, $8F, $20),
  372.                      (33, $F8, $06),   (43, $8F, $60),
  373.                      (34, $F8, $01),   (44, $8F, $10),
  374.                      (35, $F8, $05),   (45, $8F, $50),
  375.                      (36, $F8, $03),   (46, $8F, $30),
  376.                      (37, $F8, $07),   (47, $8F, $70));
  377.    BEGIN
  378.  
  379.       ASM
  380.       mov     si,OFFSET ANSIParms
  381.       xor     cx,cx
  382.       mov     cl,PNum
  383.  
  384.       or      cx,cx
  385.       jnz     @sgr_loop
  386.       mov     [si],cl
  387.       inc     cx
  388.  
  389.    @sgr_loop:
  390.       lodsb
  391.       push    cx
  392.       mov     cx,Colors
  393.       mov     bx,OFFSET ColorTbl - 3
  394.  
  395.    @sgr_search:
  396.       add     bx,3
  397.       cmp     al,[bx]
  398.       loopne  @sgr_search
  399.       jne     @sgr_loopx
  400.  
  401.       mov     cx,1[bx]
  402.       les     bx,TAttr
  403.       mov     al,es:[bx]
  404.       and     al,cl
  405.       or      al,ch
  406.       mov     es:[bx],al
  407.  
  408.    @sgr_loopx:
  409.       pop     cx
  410.       loop    @sgr_loop
  411.       END
  412.  
  413.    END;
  414.  
  415.    PROCEDURE ProcessCommand(Ch : CHAR);
  416.    VAR   loop : INTEGER;
  417.          CurL : TPoint;
  418.    BEGIN
  419.       WITH Interior^ DO BEGIN
  420.          IF (Ch = 'J') AND (ANSIParms[1] = 2) THEN   { Special Case...   }
  421.             BEGIN                                    { Handle regardless }
  422.                ClrScr;                               { of UseANSI status }
  423.                EXIT
  424.             END;
  425.          IF NOT UseANSI THEN
  426.             EXIT;
  427.          CurL.X := CurLoc.X + 1;
  428.          CurL.Y := CurLoc.Y + 1;
  429.          CASE Ch OF
  430.             '@' : ;
  431.             'A' : GotoXY(CurL.X,Max(0,CurL.Y - ANSIParms[1]));
  432.             'B' : GotoXY(CurL.X,Min(MaxDim.Y,CurL.Y + ANSIParms[1]));
  433.             'C' : GotoXY(Min(CurL.X + ANSIParms[1],MaxDim.X),CurL.Y);
  434.             'D' : GotoXY(Max(CurL.X - ANSIParms[1],0) + 1,CurL.Y);
  435.             'H','f' : BEGIN
  436.                      IF ParmsIdx < 2 THEN
  437.                         ANSIParms[2] := 1;
  438.                      ANSIParms[1] := Min(MaxDim.Y,ANSIParms[1]);
  439.                      ANSIParms[2] := Min(MaxDim.X,ANSIParms[2]);
  440.                      GotoXY(ANSIParms[2],ANSIParms[1]);
  441.                   END;
  442.             'J' : IF ANSIParms[1] = 2 THEN
  443.                      ClrScr;
  444.             'K' : ClrEol;
  445.             'L' : FOR Loop := 1 TO ANSIParms[1] DO
  446.                      InsLine;
  447.             'M' : FOR Loop := 1 TO ANSIParms[1] DO
  448.                      DelLine;
  449.             'P' : ;
  450.             'm' : ChangeTextAttr(TextAttr,ParmsIdx,ANSIParms);
  451.             's' : CurHold := CurL;
  452.             'u' : GotoXY(CurHold.X,CurHold.Y);
  453.             ELSE  EXIT
  454.          END
  455.       END;
  456.       ESCBuf := ''
  457.    END;
  458.  
  459. LABEL ReEval;
  460. VAR   i : INTEGER;
  461.  
  462. BEGIN
  463.    ProcessChar := FALSE;
  464.    IF StateInfo > 0 THEN
  465.       BEGIN
  466.          ESCBuf := ESCBuf + Ch;
  467. ReEval:
  468.          CASE StateInfo OF
  469.  
  470. {f_bracket}
  471.             1 : StateInfo := ORD(Ch = '[') SHL 1;
  472.  
  473. {f_get_args}
  474.             2 : BEGIN
  475.                    StateInfo := 3;
  476.                    ParmsIdx := 0;
  477.                    FILLCHAR(ANSIParms,SIZEOF(ANSIParms),1);
  478.                    IF (Ch <> '=') AND (Ch <> '?') THEN
  479.                       GOTO ReEval
  480.                 END;
  481.  
  482. {f_get_param}
  483.             3 : IF (Ch >= '0') AND (Ch <= '9') THEN
  484.                    BEGIN
  485.                       INC(ParmsIdx);
  486.                       ANSIParms[ParmsIdx] := ORD(Ch) - $30;
  487.                       StateInfo := 6
  488.                    END
  489.                 ELSE
  490.                    IF (Ch = '''') OR (Ch = '"') THEN
  491.                       BEGIN
  492.                          StateInfo := 4;
  493.                          EndString := Ch
  494.                       END
  495.                    ELSE
  496.                       BEGIN
  497.                          StateInfo := 7;
  498.                          GOTO ReEval
  499.                       END;
  500.  
  501. {f_get_string}
  502.             4 : INC(StateInfo,ORD(Ch = EndString))
  503.  
  504. {f_eat_semi}
  505.             5 : StateInfo := ORD(Ch = ';') * 3;
  506.  
  507. {f_in_param}
  508.             6 : IF (Ch >= '0') AND (Ch <= '9') THEN
  509.                    ANSIParms[ParmsIdx] := ANSIParms[ParmsIdx] * 10
  510.                                         + ORD(Ch) - $30
  511.                 ELSE
  512.                    BEGIN
  513.                       StateInfo := 7;
  514.                       GOTO ReEval
  515.                    END;
  516.  
  517. {fgp_semi_or_cmd}
  518.             7 : BEGIN
  519.                    StateInfo := ORD(Ch = ';') * 3;
  520.                    IF StateInfo = 0 THEN
  521.                       ProcessCommand(Ch)
  522.                 END
  523.          END;
  524.  
  525.          IF (StateInfo = 0) AND (LENGTH(ESCBuf) > 0) THEN
  526.             BEGIN
  527.                FOR i := 1 TO LENGTH(ESCBuf) DO
  528.                   Interior^.PrintChar(ESCBuf[1],TextAttr);
  529.                ESCBuf := '';
  530.                ParmsIdx := 0;
  531.                ProcessChar := TRUE
  532.             END
  533.       END
  534.    ELSE
  535.       IF Ch <> #27 THEN
  536.          BEGIN
  537.             Interior^.PrintChar(Ch,TextAttr);
  538.             ProcessChar := TRUE
  539.          END
  540.       ELSE
  541.          StateInfo := 1;
  542. END;
  543.  
  544. PROCEDURE TANSIView.PrintLN;
  545. BEGIN
  546.    Print(s + #13 + #10)
  547. END;
  548.  
  549. PROCEDURE TANSIView.Print;
  550. VAR   Loop      : INTEGER;
  551.       ValidDisp : BOOLEAN;
  552. BEGIN
  553.    IF LENGTH(s) > 0 THEN
  554.       BEGIN
  555.          ValidDisp := FALSE;
  556.          FOR Loop := 1 TO LENGTH(s) DO
  557.             ValidDisp := ProcessChar(s[Loop]) OR ValidDisp;
  558.          IF ValidDisp THEN
  559.             BEGIN
  560.                SetCursor(Interior^.CurLoc.X,Interior^.CurLoc.Y);
  561.                Interior^.DrawView
  562.             END
  563.       END
  564. END;
  565.  
  566. PROCEDURE TANSIView.PrintChar;
  567. BEGIN
  568.    IF ProcessChar(Ch) THEN
  569.       BEGIN
  570.          SetCursor(Interior^.CurLoc.X,Interior^.CurLoc.Y);
  571.          Interior^.DrawView
  572.       END
  573. END;
  574.  
  575. PROCEDURE TANSIView.PutChar;
  576. BEGIN
  577.    IF (X >= 0) AND (X < Interior^.MaxDim.X) AND
  578.       (Y >= 0) AND (Y < Interior^.MaxDim.Y) THEN
  579.       BEGIN
  580.          IF ch <> #0 THEN
  581.             WordRec(Interior^.TopPtr^[Y]^[X]).LO := ORD(Ch);
  582.          IF Attr <> 0 THEN
  583.             WordRec(Interior^.TopPtr^[Y]^[X]).HI := Attr;
  584.          Interior^.DrawView
  585.       END
  586. END;
  587.  
  588. PROCEDURE TANSIView.CursorOn;
  589. BEGIN
  590.    Interior^.ShowCursor
  591. END;
  592.  
  593. PROCEDURE TANSIView.CursorOff;
  594. BEGIN
  595.    Interior^.HideCursor
  596. END;
  597.  
  598. PROCEDURE TANSIView.AutoScrollOn;
  599. BEGIN
  600.    Interior^.AutoScroll := TRUE
  601. END;
  602.  
  603. PROCEDURE TANSIView.AutoScrollOff;
  604. BEGIN
  605.    Interior^.AutoScroll := FALSE
  606. END;
  607.  
  608. PROCEDURE TANSIView.ClrScr;
  609. VAR   i : INTEGER;
  610. BEGIN
  611.    SetCursor(0,0);
  612.    Interior^.CurLoc.X := 0;
  613.    Interior^.CurLoc.Y := 0;
  614.    FOR i := 0 TO Interior^.MaxDim.Y - 1 DO
  615.       MoveChar(Interior^.TopPtr^[i]^,' ',TextAttr,Interior^.MaxDim.X);
  616.    Interior^.VScrollBar^.SetValue(0);
  617.    Interior^.HScrollBar^.SetValue(0);
  618.    Interior^.DrawView
  619. END;
  620.  
  621. PROCEDURE TANSIView.ClrEol;
  622. BEGIN
  623.    WITH Interior^ DO BEGIN
  624.       MoveChar(TopPtr^[CurLoc.Y]^[CurLoc.X],' ',TextAttr,MaxDim.X - CurLoc.X);
  625.       DrawView
  626.    END
  627. END;
  628.  
  629. PROCEDURE TANSIView.DelLine;
  630. VAR   PPtr : PScreenL;
  631. BEGIN
  632.    WITH Interior^ DO BEGIN
  633.       PPtr := TopPtr^[CurLoc.Y];
  634.       IF CurLoc.Y < MaxDim.Y - 1 THEN
  635.          MOVE(TopPtr^[CurLoc.Y + 1],TopPtr^[CurLoc.Y],(MaxDim.Y - CurLoc.Y) * SIZEOF(PScreenL));
  636.       TopPtr^[MaxDim.Y - 1] := PPtr;
  637.       MoveChar(PPtr^,' ',TextAttr,MaxDim.X);
  638.       DrawView
  639.    END
  640. END;
  641.  
  642. PROCEDURE TANSIView.GotoXY;
  643. BEGIN
  644.    WITH Interior^ DO BEGIN
  645.       CurLoc.X := Max(X - 1,0);
  646.       CurLoc.X := Min(CurLoc.X,MaxDim.X);
  647.  
  648.       CurLoc.Y := Max(Y - 1,0);
  649.       CurLoc.Y := Min(CurLoc.Y,MaxDim.Y);
  650.       SetCursor(CurLoc.X,CurLoc.Y)
  651.    END
  652. END;
  653.  
  654. PROCEDURE TANSIView.HighVideo;
  655. BEGIN
  656.    TextAttr := TextAttr OR $08
  657. END;
  658.  
  659. PROCEDURE TANSIView.InsLine;
  660. VAR   PPtr : PScreenL;
  661. BEGIN
  662.    WITH Interior^ DO BEGIN
  663.       PPtr := TopPtr^[MaxDim.Y - 1];
  664.       IF CurLoc.Y < MaxDim.Y - 1 THEN
  665.          MOVE(TopPtr^[CurLoc.Y],TopPtr^[CurLoc.Y + 1],(MaxDim.Y - CurLoc.Y) * SIZEOF(PScreenL));
  666.       TopPtr^[CurLoc.Y] := PPtr;
  667.       MoveChar(PPtr^,' ',TextAttr,MaxDim.X);
  668.       DrawView
  669.    END
  670. END;
  671.  
  672. PROCEDURE TANSIView.LowVideo;
  673. BEGIN
  674.    TextAttr := TextAttr AND (NOT $08)
  675. END;
  676.  
  677. PROCEDURE TANSIView.TextBackground;
  678. BEGIN
  679.    TextAttr := (Color AND $03) SHL 4 + (TextAttr AND $8F)
  680. END;
  681.  
  682. PROCEDURE TANSIView.TextColor;
  683. BEGIN
  684.    TextAttr := (TextAttr AND $70) + (Color AND $0F)
  685. END;
  686.  
  687. FUNCTION TANSIView.WhereX;
  688. BEGIN
  689.    WhereX := Interior^.CurLoc.X
  690. END;
  691.  
  692. FUNCTION TANSIView.WhereY;
  693. BEGIN
  694.    WhereY := Interior^.CurLoc.Y
  695. END;
  696.  
  697. {----------------------------------------------------------------------------}
  698.  
  699. PROCEDURE RegisterANSIView;
  700. BEGIN
  701.    RegisterType(RANSIView);
  702.    RegisterType(RInterior);
  703. END;
  704.  
  705. END.